package com.zl.redisscheduler;

import java.util.List;
import java.util.Optional;
import java.util.function.Function;

public interface RedisDriver {

    <T> T fetch(Function<Commands, T> block);

    default <T> T execute(Function<Commands, T> block) {
        return  fetch((Function<Commands, T>) block::apply);
    }

    interface Commands {
        boolean addToSetWithScore(String key, String taskId, long score);

        boolean removeFromSet(String key, String taskId);

        boolean remove(String key);

        boolean watch(String key);

        boolean unwatch();

        boolean multi();

        boolean exec();

        Object eval(String var1, List<String> var2, List<String> var3);

        Optional<String> firstByScore(String key, long minScore, long maxScore);
    }
}
